package com.loong.framework.satoken;

import cn.dev33.satoken.stp.StpInterface;
import cn.dev33.satoken.stp.StpUtil;

import java.util.List;

import com.loong.framework.utils.SystemUtil;
import org.springframework.stereotype.Component;

/** 注入权限组 */
@Component
public class StpInterfaceImpl implements StpInterface {

  /**
   * 用户权限
   *
   * @param loginId 登录id
   * @param s
   * @return
   */
  @Override
  public List<String> getPermissionList(Object loginId, String s) {
    Object authList = StpUtil.getSession().get("authList");
    return SystemUtil.object2List(authList, String.class);
  }

  /**
   * 用户角色
   *
   * @param loginId 登录id
   * @param s
   * @return
   */
  @Override
  public List<String> getRoleList(Object loginId, String s) {
    Object roleList = StpUtil.getSession().get("roleList");
    return SystemUtil.object2List(roleList, String.class);
  }
}
